// const base32 = require('./src/base32.js');

import { base32 } from './hi-base32.js'

let encodeText = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed non risus. Suspendisse lectus tortor, dignissim sit amet, adipiscing nec, ultricies sed, dolor. Cras elementum ultrices diam. Maecenas ligula massa, varius a, semper congue, euismod non, mi. Proin porttitor, orci nec nonummy molestie, enim est eleifend mi, non fermentum diam nisl sit amet erat. Duis semper. Duis arcu massa, scelerisque vitae, consequat in, pretium a, enim. Pellentesque congue. Ut in risus volutpat libero pharetra tempor. Cras vestibulum bibendum augue. Praesent egestas leo in pede. Praesent blandit odio eu enim.';
let enCodeResult = 'JRXXEZLNEBUXA43VNUQGI33MN5ZCA43JOQQGC3LFOQWCAY3PNZZWKY3UMV2HK4RAMFSGS4DJONRWS3THEBSWY2LUFYQFGZLEEBXG63RAOJUXG5LTFYQFG5LTOBSW4ZDJONZWKIDMMVRXI5LTEB2G64TUN5ZCYIDENFTW42LTONUW2IDTNF2CAYLNMV2CYIDBMRUXA2LTMNUW4ZZANZSWGLBAOVWHI4TJMNUWK4ZAONSWILBAMRXWY33SFYQEG4TBOMQGK3DFNVSW45DVNUQHK3DUOJUWGZLTEBSGSYLNFYQE2YLFMNSW4YLTEBWGSZ3VNRQSA3LBONZWCLBAOZQXE2LVOMQGCLBAONSW24DFOIQGG33OM52WKLBAMV2WS43NN5SCA3TPNYWCA3LJFYQFA4TPNFXCA4DPOJ2HI2LUN5ZCYIDPOJRWSIDOMVRSA3TPNZ2W23LZEBWW63DFON2GSZJMEBSW42LNEBSXG5BAMVWGK2LGMVXGIIDNNEWCA3TPNYQGMZLSNVSW45DVNUQGI2LBNUQG42LTNQQHG2LUEBQW2ZLUEBSXEYLUFYQEI5LJOMQHGZLNOBSXELRAIR2WS4ZAMFZGG5JANVQXG43BFQQHGY3FNRSXE2LTOF2WKIDWNF2GCZJMEBRW63TTMVYXKYLUEBUW4LBAOBZGK5DJOVWSAYJMEBSW42LNFYQFAZLMNRSW45DFONYXKZJAMN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3SMFZSA5TFON2GSYTVNR2W2IDCNFRGK3TEOVWSAYLVM52WKLRAKBZGCZLTMVXHIIDFM5SXG5DBOMQGYZLPEBUW4IDQMVSGKLRAKBZGCZLTMVXHIIDCNRQW4ZDJOQQG6ZDJN4QGK5JAMVXGS3JO';
let decodeResult = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed non risus. Suspendisse lectus tortor, dignissim sit amet, adipiscing nec, ultricies sed, dolor. Cras elementum ultrices diam. Maecenas ligula massa, varius a, semper congue, euismod non, mi. Proin porttitor, orci nec nonummy molestie, enim est eleifend mi, non fermentum diam nisl sit amet erat. Duis semper. Duis arcu massa, scelerisque vitae, consequat in, pretium a, enim. Pellentesque congue. Ut in risus volutpat libero pharetra tempor. Cras vestibulum bibendum augue. Praesent egestas leo in pede. Praesent blandit odio eu enim.';


function encode32() {
  let enCodeStr = ''
  let startTime = Date.now();
  for (let i = 0; i < 10000; i++) {
    enCodeStr = base32.encode(encodeText);
  }
  let endTime = Date.now();
  if (enCodeStr != enCodeResult) {
    throw 'base32.encode error'
  }
  // console.log(`hi-base32Demo_encode_001: ${endTime - startTime} ms`)
  print(`hi-base32Demo_decode_001: ${endTime - startTime} ms`)

}


function decode32() {
  let decodeStr = ''
  let startTime = Date.now();
  for (let i = 0; i < 10000; i++) {
    decodeStr = base32.decode(decodeText);
  }
  let endTime = Date.now();
  if (decodeStr != decodeResult) {
    throw 'base32.decode error'
  }
  // console.log(`hi-base32Demo_decode_002: ${endTime - startTime} ms`)
  print(`hi-base32Demo_decode_002: ${endTime - startTime} ms`)
}

function hibaseTest() {
  encode32();
  decode32();
}

hibaseTest()